# -*- coding:utf8 -*- #
# -----------------------------------------------------------------------------------
# ProjectName:  property-ui-auto-test
# FileName:     virtual_meter_group.py
# Author  :
# Datetime:     2022/9/29 10:43
# Description：
# -----------------------------------------------------------------------------------
from time import sleep

from page.login_page import LoginPage


class VirtualMeterGroup(LoginPage):
    def virtual_meter_setup(self):
        # 点击展开
        self.click('//*[@id="app"]/section/section/aside/div/img')
        sleep(0.5)
        # 点击虚拟电表
        self.click('//*[@id="app"]/section/section/aside/div/div/ul/li[10]')
        # 新增虚拟电表

    def virtual_meter_add(self, merchantName="test", balance=1, alertAmount=100, overdraft=100, grouping="数据项目-4",
                          optPwd=123123):
        """
            暂未使用
        :param merchantName:
        :param balance:
        :param alertAmount:
        :param overdraft:
        :param grouping:
        :param optPwd:
        :return:
        """
        pass
        # 调用前置步骤
        # self.virtual_meter_setup()
        # # 点击新增
        # self.click('//*[@id="app"]/section/section/main/section/section/section/header/div/div/form/div[3]/div/button')
        # # 点击文本框
        # self.click(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[1]/div/div/div[1]/input')
        # sleep(1)
        # # 选择分组
        # self.driver.find_elements_by_class_name('el-popper')[1].find_elements_by_class_name('el-radio__inner')[
        #     0].click()
        # # 点击空白处
        # self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[1]/span')
        # # 输入商户名
        # self.send_keys(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[2]/div/div/input',
        #     merchantName)
        # # 输入余额
        # self.send_keys(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[3]/div/div/input',
        #     balance)
        # # 输入告警额
        # self.send_keys(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[4]/div/div/input',
        #     alertAmount)
        # # 输入透支额
        # self.send_keys(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[5]/div/div/input',
        #     overdraft)
        # # 选择付费方式
        # self.click(
        #     '//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[2]/form/div[7]/div/div/label[1]/span[1]/span')
        # # 点击提交
        # self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[2]/div/div[3]/div/button[2]')
        # sleep(0.1)
        # # 输入操密码
        # self.send_keys('/html/body/div[3]/div/div[2]/div[2]/div[1]/input', optPwd)
        # # 点击提交
        # self.click('/html/body/div[3]/div/div[3]/button[2]')

        # 绑定真实电表

    def virtual_meter_bindAdd(self, optPwd=123123):
        # 调用前置条件
        self.virtual_meter_setup()
        # 点击数字
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[1]/div[3]/table/tbody/tr[1]/td[7]/div/a/span')
        # 点击新增电表
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[4]/div/div/div[2]/div[2]/div/a/span')
        sleep(1)
        # 勾选
        self.click('/html/body/div[3]/div/div[2]/div[2]/ul/li[1]/label/span[1]/span')
        # 点击确定
        self.click('/html/body/div[2]/div/div[3]/span/button[2]')
        # 点击确定
        self.click('/html/body/div[3]/div/div[3]/button[2]')
        # 输入操作密码
        self.send_keys('/html/body/div[3]/div/div[2]/div[2]/div[1]/input', optPwd)
        # 点击确定
        self.click('/html/body/div[3]/div/div[3]/button[2]')

        # 删除绑定的真实电表

    def virtual_meter_bindDel(self, optPwd=123123):
        self.virtual_meter_setup()
        # 点击数字
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[1]/div[3]/table/tbody/tr/td[5]/div/a/span')
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[4]/div/div/div[2]/div[3]/div[3]/table/tbody/tr/td[10]/div/img')
        self.send_keys('/html/body/div[2]/div/div[2]/div[2]/div[1]/input', optPwd)
        self.click('/html/body/div[2]/div/div[3]/button[2]')
        # 点击关闭
        self.click('//*[@id="app"]/section/section/main/section/section/section/main/div[4]/div/div/div[3]/span/button')

        # 余额调整

    def virtual_meter_balanceUpdate(self, balanceUpdate=100, remark=1, optPwd=123123):
        # 调用前置条件
        self.virtual_meter_setup()
        # 点击余额调整
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[1]/div[3]/table/tbody/tr[1]/td[10]/div/img[2]')
        # 调整后余额
        self.send_keys(
            '//*[@id="app"]/section/section/main/section/section/div/div/div[2]/form/div[4]/div/div/div/input',
            balanceUpdate)
        # 备注
        self.send_keys('//*[@id="app"]/section/section/main/section/section/div/div/div[2]/form/div[5]/div/div/input',
                       remark)
        # 确定
        self.click('//*[@id="app"]/section/section/main/section/section/div/div/div[3]/span/button[2]')
        sleep(0.5)
        # 输入密码
        self.send_keys('/html/body/div[2]/div/div[2]/div[2]/div[1]/input', optPwd)
        # 确定
        self.click('/html/body/div[2]/div/div[3]/button[2]')

        # 删除虚拟电表

    def virtual_meter_del(self, optPwd=123123):
        # 调用前置条件
        self.virtual_meter_setup()
        # 删除
        self.click(
            '//*[@id="app"]/section/section/main/section/section/section/main/div[1]/div[3]/table/tbody/tr[1]/td[10]/div/img[5]')
        # 确定
        self.click('/html/body/div[2]/div/div[3]/button[2]')
        # 输入密码
        self.send_keys('/html/body/div[2]/div/div[2]/div[2]/div[1]/input', optPwd)
        # 确定
        self.click('/html/body/div[2]/div/div[3]/button[2]')
if __name__ == '__main__':
    vmg = VirtualMeterGroup()
    vmg.login()
    # vmg.virtual_meter_add()
    vmg.virtual_meter_bindAdd()
    # vmg.virtual_meter_bindDel()
    # vmg.virtual_meter_balanceUpdate()
    # vmg.virtual_meter_del()
    sleep(5)
    vmg.quit()